package com.tian.controller;

import com.tian.pojo.Lead;
import com.tian.service.LeadService;
import com.tian.vo.PageResult;
import com.tian.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/lead/")
public class LeadController {

    @Autowired
    private LeadService leadService;


    @GetMapping("/list")
    public SysResult getUserList(PageResult pageResult){
        pageResult = leadService.getUserList(pageResult);
        return SysResult.success(pageResult);
    }

    @DeleteMapping("deleteLeadById")
    public SysResult deleteLeadById(Integer id){
        leadService.deleteLeadById(id);
        return SysResult.success();
    }

    @GetMapping("{id}")
    public SysResult selectById(@PathVariable Integer id){
        return SysResult.success(leadService.selectById(id));
    }

    @PutMapping("updateLead")
    public SysResult updateLead(@RequestBody Lead lead){
        leadService.updateLead(lead);
        return SysResult.success();
    }
}
